import React, {Component} from 'react';
import PageList from "./PageList";
class CommentOn extends Component {
    // 点赞，踩
    putWeibo = (id,type)=>{
        return async e=>{
            e.preventDefault()
            await this.$http.put(`/weibo/${id}/${type}`)
            this.props.getCommon(this.props.pageNo)
        }
    }
    // 删除微博评论
    deleteWeibo = (id)=>{
        return async e=>{
            await this.$http.delete(`/weibo/${id}`)
            this.props.getCommon(this.props.pageNo)
        }
    }
  render() {
    const {contentList} = this.props
    return (
        <div className="commentOn">
            <div className="noContent" style={{display:contentList.length===0? 'block':'none'}}>暂无留言</div>
            {
                contentList.map(item=>{
                    return (
                        <div className="messList" key={item._id}>
                            <div className="reply">
                                <p className="replyContent">{item.content}</p>
                                <p className="operation">
                                    <span className="replyTime">{item.addTime}</span>
                                    <span className="handle">
                                        <a href="" onClick={this.putWeibo(item._id,1)} className="top">{item.topNum}</a>
                                        <a href="" onClick={this.putWeibo(item._id,2)} className="down_icon">{item.downNum}</a>
                                        <a href="" onClick={this.deleteWeibo(item._id)} className="cut">删除</a>
                                    </span>
                                </p>
                            </div>
                        </div>
                    )
                })
            }
            <PageList {...this.props}/>
    </div>
    )
  }
}

export default CommentOn